﻿using BestCode.Creds.Entities;
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;

namespace BestCode.Creds.Data.Mappings
{
    public class DUA_PersonaMapping : ClassMapping<DUA_Persona>
    {
        public DUA_PersonaMapping()
        {
            Table("DUA_Persona");
            Id(p => p.Id, map =>
            {
                map.Column("PersonaId");
                map.Generator(Generators.Identity);
            });
            Property(p => p.CodRegion);
            Property(p => p.Guid);
            Property(p => p.Lenguaje);
        }
    }


    public class FieldDefinitionMapping :  JoinedSubclassMapping<FieldDefinition>
    {
        public FieldDefinitionMapping()
        {
            Table("FieldDefinition");
            Key(p => p.Column("FieldDefinitionId"));
 

            Property(p=> p.Code);
            Property(p => p.FirstName);
            Property(p => p.SecondName);
            Property(p => p.LastName1);
            Property(p => p.LastName2);
            Property(p => p.BloodType);
            Property(p => p.MedicalReport);


            Property(p => p.Address);
            Property(p => p.AddressZone);
            Property(p => p.Especiality);
            Property(p => p.WorkPhone);
            Property(p => p.CellPhone);
            Property(p => p.ContactPersonName);
            Property(p => p.Picture);
            Property(p => p.BarCodeString);

            Property(p=> p.Gender);
            Property(p=> p.DateOfBirth);
            Property(p => p.IsEnabled);
            Property(p => p.CI);

            ManyToOne(p => p.Entity, map => map.Column("EntityId"));
            ManyToOne(p => p.EntityChild, map => map.Column("EntityChildId"));
            
        } 
    }
}
